<template>
  <div id="app">
    <router-view v-if="isRouterAlive" />
  </div>
</template>
<script>
import API from "@/network/api/loginApi";
export default {
  name: "app",
  provide() {
    // 父组件中通过provide来提供变量，在子组件中通过inject来注入变量。
    return {
      reload: this.reload,
      center: {
        textAlign: "center"
      }
    };
  },
  data() {
    return {
      isRouterAlive: true
    };
  },
  mounted() {
    const domain = document.domain;
    API.getDomain({ domain: domain }).then(res => {
      // console.log(res.data.data)
      if (res.data.code === 0) {
        document.title = res.data.data.organName;
        document.logoPath = res.data.data.logoPath;
      } else {
        this.$message({
          type: "warning",
          message: res.data.msg
        }).catch(err => {
          alert(err);
        });
      }
    });
  },
  methods: {
    reload() {
      this.isRouterAlive = false;
      this.$nextTick(function() {
        this.isRouterAlive = true;
      });
    }
  }
};
</script>
<style>
* {
  box-sizing: border-box;
}
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
}

#app,
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

#nav {
  padding: 30px;
}

#nav a {
  font-weight: bold;
  color: #2c3e50;
}

#nav a.router-link-exact-active {
  color: #4295ff;
}
</style>
